﻿using System;
using System.Collections.Generic;
using System.Text;
using Wire;
using System.Windows.Forms;
using Settings = QuickTools.ProcessHelper.Properties.Settings;
using QuickTools.ProcessHelper;
using System.Threading;

namespace quickTools.ProcessHelper
{
    public class ProcessHelper : Plugin
    {
        private const string PluginTitle = "quickTools MatchmediaHelper";
        private const string ShortTitle = "MatchmediaHelper";
        private GameInterface gameInterface;
        private ProcessModule processModule = new ProcessModule();
        static ProcessHelper()
        {
            if (Settings.Default.NewVersionInstalled)
            {
                Settings.Default.Upgrade();
                Settings.Default.NewVersionInstalled = false;
                Settings.Default.Save();
            }

            Application.EnableVisualStyles();
        }

        #region plugin interface

        private void showSettings()
        {
            try
            {
                SettingsWindow w = new SettingsWindow(processModule);
                w.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

        public override void iconClicked(int x, int y, Plugin.MouseButton button)
        {
            Thread windowThread = new Thread(new ThreadStart(showSettings));
            windowThread.SetApartmentState(ApartmentState.STA);
            windowThread.Start();
            /*switch (button)
            {
                case MouseButton.RightButton:
                    contextMenu.Show(x, y);
                    break;
                case MouseButton.LeftButton:
                    ShowSettings(null, EventArgs.Empty);
                    break;
            }*/
            base.iconClicked(x, y, button);
        }

        public override string Author
        {
            get { return "Lucas Romero"; }
        }

        public override string Title
        {
            get { return PluginTitle; }
        }

        private static readonly Version version = typeof(ProcessHelper).Assembly.GetName().Version;
        public override string Version
        {
            get
            {
                return version.ToString();
            }
        }

        // Init the plugin
        public override void init()
        {
            setIcon(QuickTools.ProcessHelper.Properties.Resources.icon);
        }

        #endregion
    }
}
